package com.crl.net
{
	import flash.events.EventDispatcher;
	
	
	/**
	 * 加载池;
	 * @author crl
	 * 
	 */	
	public class LoaderPool extends EventDispatcher
	{
		private var tasks:Array;
		protected var threadCount:int;
		
		public function LoaderPool(threadCount:int=2)
		{
			tasks=[];
			setThreadCount(threadCount);
		}
		
		public function addLoadTask(task:ILoaderTask):void{
			tasks.push(task);
		}
		
		public function setThreadCount(threadCount:int):void{
			if(threadCount < 1){
				throw new RangeError("threadCount must be bigger than 0 !("+threadCount+")");
			}
			var old:int = this.threadCount;
			if(old != threadCount){
				this.threadCount = threadCount;
			}
		}
	}
}